VMemoryContentsFigures, Tables, and ListingsAbout This BookFormat of a Typical ChapterConventions Used in This BookSpecial FontsTypes of NotesAssembly-Language InformationDevelopment Environment!Introduction to Memory ManagementAbout Memory.Organization of Memory by the Operating System=Figure 1-1 Memory organization with several applications openThe System HeapThe System Global Variables2Organization of Memory in an Application Partition3Figure 1-2 Organization of an application partitionThe Application Stack Figure 1-3 The application stackThe Application HeapFigure 1-4 A fragmented heapFigure 1-5 A compacted heap-The Application Global Variables and A5 World4Figure 1-6 Organization of an application’s A5 worldTemporary Memory;Figure 1-7 Using temporary memory allocated from unused RAMVirtual MemoryAddressing ModesHeap Management%Relocatable and Nonrelocatable Blocks.Figure 1-8 A pointer to a nonrelocatable block*Figure 1-9 A handle to a relocatable block Properties of Relocatable Blocks(Locking and Unlocking Relocatable Blocks+Purging and Reallocating Relocatable Blocks8Figure 1-10 Purging and reallocating a relocatable blockMemory Reservation-Figure 1-11 Allocating a nonrelocatable blockHeap Purging and CompactionHeap Fragmentation"Deallocating Nonrelocatable BlocksReserving MemoryLocking Relocatable Blocks+Figure 1-12 An effectively partitioned heap Allocating Nonrelocatable Blocks#Summary of Preventing FragmentationDangling PointersCompiler Dereferencing6Listing 1-1 Locking a block to avoid dangling pointersLoading Code SegmentsCallback RoutinesInvalid HandlesDisposed HandlesEmpty HandlesFake Handles"Listing 1-2 Creating a fake handleLow-Memory ConditionsMemory CushionsMemory ReservesGrow-Zone FunctionsUsing MemorySetting Up the Application HeapChanging the Size of the StackBListing 1-3 Increasing the amount of space allocated for the stackExpanding the Heap Allocating Master Pointer Blocks6Listing 1-4 Setting up your application heap and stack%Determining the Amount of Free MemoryRListing 1-5 Determining whether allocating memory would deplete the memory cushionAllocating Blocks of Memory)Listing 1-6 Allocating relocatable blocks,Listing 1-7 Allocating nonrelocatable blocks&Listing 1-8 Allocating a dialog recordMaintaining a Memory Reserve0Listing 1-9 Creating an emergency memory reserve2Listing 1-10 Checking the emergency memory reserveSListing 1-11 Determining whether allocating memory would deplete the memory cushion6Listing 1-12 Reallocating the emergency memory reserveDefining a Grow-Zone FunctionAListing 1-13 A grow-zone function that releases emergency storageMemory Management ReferenceMemory Management RoutinesSetting Up the Application HeapMaxApplZoneMoreMastersGetApplLimitSetApplLimit5Allocating and Releasing Relocatable Blocks of Memory NewHandleNewHandleClearDisposeHandle8Allocating and Releasing Nonrelocatable Blocks of MemoryNewPtrNewPtrClear
DisposePtr,Setting the Properties of Relocatable Blocks HGetState HSetStateHLockHUnlockHPurgeHNoPurgeManaging Relocatable BlocksEmptyHandleReallocateHandle
ReserveMemMoveHHiHLockHiManipulating Blocks of Memory BlockMoveAssessing Memory Conditions
PurgeSpaceMemErrorGrow-Zone OperationsSetGrowZone GZSaveHnd%Setting and Restoring the A5 RegisterSetCurrentA5SetA5Application-Defined RoutinesGrow-Zone Functions
MyGrowZoneSummary of Memory ManagementMemory ManagerAbout the Memory ManagerTemporary MemoryMultiple Heap ZonesThe System Global VariablesUsing the Memory Manager+Reading and Writing System Global Variables9Listing 2-1 Reading the value of a system global variable:Listing 2-2 Changing the value of a system global variable!Extending an Application’s MemoryAllocating Temporary Memory,Determining the Features of Temporary MemoryGListing 2-3 Determining whether temporary-memory routines are availableUsing the System Heap*Listing 2-4 Calling a procedure by address!Allocating Memory at Startup TimeCreating Heap ZonesDListing 2-5 Creating a subzone of the original application heap zone$Installing a Purge-Warning Procedure%Listing 2-6 A purge-warning procedure0Listing 2-7 Installing a purge-warning procedureQListing 2-8 A purge-warning procedure that calls the Resource Manager’s procedureOrganization of Memory
Heap ZonesBlock Headers*Figure 2-1 A block header in a 24-bit zone*Figure 2-2 A block header in a 32-bit zoneMemory Manager Reference
Data TypesMemory Manager RoutinesSetting Up the Application HeapMaxApplZoneMoreMasters5Allocating and Releasing Relocatable Blocks of Memory NewHandleNewHandleSysNewHandleClearNewHandleSysClearNewEmptyHandleNewEmptyHandleSysDisposeHandle8Allocating and Releasing Nonrelocatable Blocks of MemoryNewPtr NewPtrSysNewPtrClearNewPtrSysClear
DisposePtr;Changing the Sizes of Relocatable and Nonrelocatable BlocksGetHandleSizeSetHandleSize
GetPtrSize
SetPtrSize,Setting the Properties of Relocatable Blocks HGetState HSetStateHLockHUnlockHPurgeHNoPurgeHSetRBitHClrRBitManaging Relocatable BlocksEmptyHandleReallocateHandleRecoverHandle
ReserveMemReserveMemSysMoveHHiHLockHiManipulating Blocks of Memory BlockMove PtrToHand
MyGrowZonePurge-Warning ProceduresMyPurgeProcSummary of the Memory ManagerVirtual Memory Manager About the Virtual Memory ManagerVirtual MemoryThe Logical Address Space24-Bit Addressing6Figure 3-1 24-bit Memory Manager logical address space32-Bit Addressing6Figure 3-2 32-bit Memory Manager logical address spaceThe Physical Address SpaceJFigure 3-3 The physical address space on a Macintosh IIci with 8 MB of RAMPage Faults!Using the Virtual Memory Manager*Obtaining Information About Virtual MemoryHolding and Releasing MemoryLocking and Unlocking Memory%Mapping Logical to Physical Addresses5Listing 3-1 Translating logical to physical addresses!Deferring User Interrupt HandlingVirtual Memory and DebuggersBus-Error Vectors#Special Nonmaskable Interrupt NeedsSupervisor ModeThe Debugging StateKeyboard InputPage States Virtual Memory Manager ReferenceData StructuresMemory-Block RecordTranslation TableRoutinesVirtual Memory Management
HoldMemoryUnholdMemory
LockMemoryLockMemoryContiguousUnlockMemoryGetPhysicalDeferUserFn(Virtual Memory Debugger Support RoutinesDebuggerGetMaxDebuggerEnterDebuggerExitPageFaultFatalDebuggerLockMemoryDebuggerUnlockMemoryDebuggerPollGetPageState&Summary of the Virtual Memory ManagerMemory Management UtilitiesThe Memory Control Panel#Figure 4-1 The Memory control panel%About the Memory Management UtilitiesThe A5 RegisterAddressing ModesAddress TranslationProcessor Caches5Table 4-1 Caches available in MC680x0 microprocessorsStale Instructions
Stale Data%Figure 4-2 Initializing a status codeFigure 4-3 Reading stale data'Figure 4-4 Reading invalid instructions%Using the Memory Management Utilities-Accessing the A5 World in Completion Routines'Listing 4-1 A sample grow-zone function)Accessing the A5 World in Interrupt Tasks;Listing 4-2 Passing A5 to a notification response procedureFListing 4-3 Setting up and restoring the A5 register at interrupt time4Using QuickDraw Global Variables in Stand-Alone Code7Listing 4-4 Structure of the QuickDraw global variables@Listing 4-5 Copying the QuickDraw global variables into a recordWListing 4-6 A control’s draw routine using the calling application’s QuickDraw patternsSwitching Addressing Modes)Listing 4-7 Stripping the program counter)Stripping Flag Bits From Memory Addresses5Listing 4-8 Stripping addresses in time-critical code-Listing 4-9 Calculating the StripAddress maskTranslating Memory Addresses3Listing 4-10 Translating 24-bit to 32-bit addresses%Memory Management Utilities ReferenceRoutines%Setting and Restoring the A5 RegisterSetCurrentA5SetA5Changing the Addressing Mode
GetMMUModeSwapMMUModeManipulating Memory AddressesStripAddressTranslate24To32!Manipulating the Processor CachesSwapInstructionCacheFlushInstructionCacheSwapDataCacheFlushDataCacheFlushCodeCacheFlushCodeCacheRange+Summary of the Memory Management UtilitiesGlossaryIndex